#ifndef IMAGEPROVIDER_H
#define IMAGEPROVIDER_H

#include <QObject>
#include <QImage>
#include <QMap>
#include <QQuickImageProvider>

class ImageProvider : public QObject, public QQuickImageProvider
{
    Q_OBJECT

public:
    ImageProvider();
    ~ImageProvider();

public:
    QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
    //QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize);

public:
    static ImageProvider* GetInstance();

public:
    void setImage(const QString &id, const QImage &image);
    QImage* findImage(const QString& fileName);

protected:

private:
    QMap<QString, QImage> m_MapImages;
};

/***********************************************/

class ShowImage : public QObject
{
    Q_OBJECT
public:
    explicit ShowImage(QObject *parent = 0);
    ~ShowImage();
    //ImageProvider *m_pImgProvider = nullptr;

public slots:
    void doAddImage(const QString &id, const QImage &image);

public:
    ImageProvider* getInstance();

signals:
    void callQmlRefeshImg();
};

#endif // IMAGEPROVIDER_H
